package day1.problem3;

//AB5.点击消除
//https://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5?tpId=308&tqId=40462&ru=/exam/oj

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        Stack<Character> stack = new Stack<>();
        for(int i = 0; i<str.length(); i++) {
            char ch = str.charAt(i);
            if(stack.isEmpty() || stack.peek() != ch) {
                stack.push(ch);
            }else {
                while(!stack.isEmpty() && stack.peek() == ch) {
                    stack.pop();
                }
            }
        }
        StringBuffer ret = new StringBuffer();
        while(!stack.isEmpty()) {
            ret.append(stack.pop());
        }
        if(ret.length() == 0) System.out.println(0);
        else System.out.println(ret.reverse());
    }
}